

function twoSumFinal(nums: number[], target: number): number[] {
    let map = new Map<number, number>();
    let length = nums.length;
    for (let i = 0; i < length; i++) {
        let num = nums[i];
        let prevIndex = map.get(target - num);
        if (prevIndex !== undefined) {
            return [prevIndex, i];
        }
        map.set(num, i)
    }
    return [-1, -1];
};
